//
//  LoginView.m
//  fitnessmanage
//
//  Created by 众拳科技 on 2017/10/16.
//  Copyright © 2017年 zongquankeji. All rights reserved.
//

#import "LoginView.h"
//#import "RegFirstViewController.h"

@interface LoginView()

@end

@implementation LoginView

-(id)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        //self.backgroundColor = CSColor(35, 36, 40);
        
        /**
         背景图片
         */
        UIImageView *bgImageView = [[UIImageView alloc] init];
        bgImageView.image = [UIImage imageNamed:@"bg"];
        [self addSubview:bgImageView];
        self.bgImageView = bgImageView;
        
        /**
         登录Logo
         */
        UIImageView *loginImageView = [[UIImageView alloc] init];
        loginImageView.image = [UIImage imageNamed:@"regLogo"];
        [self addSubview:loginImageView];
        self.loginImageView = loginImageView;
        
        /**
         登录按钮
         */
        UIButton *loginBtn = [[UIButton alloc] init];
        loginBtn.backgroundColor = [CSColorFromRGB(0xffffff) colorWithAlphaComponent:0.5];
        loginBtn.layer.cornerRadius = 4;
        loginBtn.layer.masksToBounds = YES;
        [loginBtn setTitleColor:CSBlackColor forState:UIControlStateNormal];
        [loginBtn setTitle:@"用户登录" forState:UIControlStateNormal];
        
        loginBtn.titleLabel.font = BigFont;
        [self addSubview:loginBtn];
        self.loginBtn = loginBtn;
        
        /**
         注册按钮
         */
        UIButton *regBtn = [[UIButton alloc] init];
        regBtn.backgroundColor = [UIColor yellowColor];
        regBtn.layer.cornerRadius = 4;
        regBtn.backgroundColor = CSColorFromRGB(0xfee100);
        regBtn.layer.masksToBounds = YES;
        [regBtn setTitleColor:CSBlackColor forState:UIControlStateNormal];
        [regBtn setTitle:@"账号注册" forState:UIControlStateNormal];
        
        regBtn.titleLabel.font = BigFont;
        [self addSubview:regBtn];
        self.regBtn = regBtn;
        
        /**
         第三方登录
         */
        ThirdLoginView *thirdLoginView  = [[ThirdLoginView alloc] init];
        [self addSubview:thirdLoginView];
        self.thirdLoginView = thirdLoginView;
        
        [self setConstraints];
    }
    
    return self;
    
}

-(void)setConstraints{
    
    /**
     背景图片
     */
    [self.bgImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.mas_equalTo(self);
    }];
    
    /**
     登录Logo
     */
    [self.loginImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.bottom.mas_equalTo(self.mas_centerY).offset(-80);
        
        make.centerX.mas_equalTo(self);
    }];
    
    /**
     登录按钮
     */
    [self.loginBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.bottom.mas_equalTo(self.regBtn.mas_top).offset(-15);
        
        make.left.mas_equalTo(self).offset(30);
        
        make.right.mas_equalTo(self).offset(-30);
        
        make.height.mas_equalTo(50);
    }];
    
    /**
     注册按钮
     */
    [self.regBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.bottom.mas_equalTo(self.thirdLoginView.mas_top).offset(-60);
        
        make.left.width.height.mas_equalTo(self.loginBtn);
    }];
    
    /**
     第三方登录
     */
    [self.thirdLoginView mas_remakeConstraints:^(MASConstraintMaker *make) {
    
        
        make.left.width.mas_equalTo(self);
        
        make.bottom.mas_equalTo(self).offset(-20);
    }];
    
}

@end
